/*
 * Function1D.hpp
 *
 *  Created on: 2012/7/28
 *      Author: soniclin
 */

#ifndef FUNCTION_1D_HPP
#define FUNCTION_1D_HPP

#include "Function1D.h"

namespace ibm
{

template<typename T>
Function1D<T>::Function1D(T inDrift_in, T inDrift_out)
:drift_in(inDrift_in), drift_out(inDrift_out)
{

}

template<typename T>
T Function1D<T>::operator()(const sMathLib::VectorX<int, 3>& iPos, const Sphere<T, ImmersedObject>& sphere)
{
	sMathLib::VectorX<T, 3> rVector(iPos.x()-sphere.getPosition().x(), iPos.y()-sphere.getPosition().y(), iPos.z()-sphere.getPosition().z());
	//
	sMathLib::Vector3 tangentialVelocity = sMathLib::cross(sphere.getAngularVelocity(), rVector);
	T r = rVector.abs();

	//calculate phi
	T dist = r - sphere.getRadius();
	return dist < -drift_in ? 1.0 : (dist < drift_out ? 1.-(dist + drift_in)/(drift_in + drift_out) : 0.);
}

}

#endif /* FUNCTION_1D_HPP */
